<?php
    @header("Content-Type:text/html;charset=utf-8");

    @include_once("conn.php");

    if(!(isset($_POST["user"])&&isset($_POST["pwd"])&&isset($_POST["phone"])&&isset($_POST["email"]))){
        $obj = array();
        $obj["status"] = false;
        $obj["msg"] = "请传入完整参数";
        $json = json_encode($obj);
        exit($json);
    }

    $user = $_POST["user"];
    $pwd = $_POST["pwd"];
    $phone = $_POST["phone"];
    $email = $_POST["email"];


    $sql = "insert into `userinfo`(user,pwd,phone,email) values('$user','$pwd','$phone','$email')";

    // 执行mysql语句
    $result = mysqli_query($conn,$sql);
    // print_r($result);

    $obj = array();
    if($result){

        $rows = mysqli_affected_rows($conn);

        // echo $rows;
        if($rows>0){ // 新增成功
            $obj["status"] = true;
            $obj["msg"] = "新增成功";
        }else{
            $obj["status"] = false;
            $obj["msg"] = "新增失败";
        }

    }else{
        $obj["status"] = false;
        $obj["msg"] = "sql语句有误";
        $obj["sql"] = $sql;
    }

    echo json_encode($obj);

?>